package com.wj.rpsm.admin.pojo;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author WeiJin
 * @version 1.0
 */
@Data
public class ResponsePojo<T> {
    @ApiModelProperty(value="响应的数据")
    private T data;
    @ApiModelProperty("响应的说明信息")
    private String message;
    @ApiModelProperty("响应的状态码，1：成功，2：失败")
    private int code;

    private ResponsePojo(T t){
        this.data = t;
        this.code = 1;
        this.message = "";
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    private ResponsePojo(T t, String message, int code) {
        this.data = t;
        this.code = code;
        this.message = message;
    }

    public static <T> ResponsePojo<T> success(T t) {
        return new ResponsePojo(t);
    }

    public static <T> ResponsePojo<T> fail(T t, String message) {
        return new ResponsePojo(t, message, 2);
    }
}
